<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: dark)"><meta name="generator" content="Hexo 5.4.2">

  <link rel="apple-touch-icon" sizes="180x180" href="https://static.xiaosige.com/img/favicon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="https://static.xiaosige.com/img/favicon.png">
  <link rel="icon" type="image/png" sizes="16x16" href="https://static.xiaosige.com/img/favicon.png">
  <link rel="mask-icon" href="https://static.xiaosige.com/img/favicon.png" color="#222">
  <meta name="baidu-site-verification" content="WZilU4QiSZ">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.1/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.31/dist/fancybox/fancybox.css" integrity="sha256-gkQVf8UKZgQ0HyuxL/VnacadJ+D2Kox2TCEBuNQg5+w=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"www.xiaosige.com","root":"/","images":"/images","scheme":"Gemini","darkmode":true,"version":"8.26.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"hljswrap":false,"codeblock":{"theme":{"light":"atom-one-dark-reasonable","dark":"atom-one-dark-reasonable"},"prism":{"light":"prism-tomorrow","dark":"prism-tomorrow"},"copy_button":{"enable":true,"style":"mac"},"fold":{"enable":false,"height":500},"language":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":"changyan","storage":true,"lazyload":true,"nav":null,"activeClass":"changyan"},"stickytabs":false,"motion":{"enable":true,"async":false,"duration":200,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"top_n_per_article":1,"unescape":false,"preload":true,"trigger":"auto"}}</script><script src="/js/config.js" defer></script>

    <meta name="description" content="安装harbor之前先安装docker准备禁用iptables和firewalld服务[root@master ~]# systemctl stop firewalld [root@master ~]# systemctl disable firewalld [root@master ~]# systemctl stop iptables [root@master ~]# systemctl di">
<meta property="og:type" content="article">
<meta property="og:title" content="【Docker】之Harbor私有镜像仓库">
<meta property="og:url" content="https://www.xiaosige.com/post/e3fb4d65.html">
<meta property="og:site_name" content="小四儿">
<meta property="og:description" content="安装harbor之前先安装docker准备禁用iptables和firewalld服务[root@master ~]# systemctl stop firewalld [root@master ~]# systemctl disable firewalld [root@master ~]# systemctl stop iptables [root@master ~]# systemctl di">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/ca.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/ym.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/fx.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/index.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/login.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/pro.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/pro001.webp">
<meta property="og:image" content="https://www.xiaosige.com/post/e3fb4d65/jx.webp">
<meta property="article:published_time" content="2023-11-24T00:35:50.000Z">
<meta property="article:modified_time" content="2023-11-24T07:12:16.468Z">
<meta property="article:author" content="leeze">
<meta property="article:tag" content="Harbor">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://www.xiaosige.com/post/e3fb4d65/ca.webp">


<link rel="canonical" href="https://www.xiaosige.com/post/e3fb4d65.html">


<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://www.xiaosige.com/post/e3fb4d65.html","path":"post/e3fb4d65.html","title":"【Docker】之Harbor私有镜像仓库"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>【Docker】之Harbor私有镜像仓库 | 小四儿</title>
  

  <script src="/js/third-party/analytics/baidu-analytics.js" defer></script>
  <script async src="https://hm.baidu.com/hm.js?7a645cfcecaf8f711cd7518386adcc74"></script>







  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous" defer></script>
  <script src="https://cdn.jsdelivr.net/npm/@next-theme/pjax@0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous" defer></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.31/dist/fancybox/fancybox.umd.js" integrity="sha256-a+H7FYzJv6oU2hfsfDGM2Ohw/cR9v+hPfxHCLdmCrE8=" crossorigin="anonymous" defer></script>
  <script src="https://cdn.jsdelivr.net/npm/lozad@1.16.0/dist/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous" defer></script>
<script src="/js/utils.js" defer></script><script src="/js/motion.js" defer></script><script src="/js/sidebar.js" defer></script><script src="/js/next-boot.js" defer></script><script src="/js/pjax.js" defer></script>

  <script src="https://cdn.jsdelivr.net/npm/hexo-generator-searchdb@1.5.0/dist/search.js" integrity="sha256-xFC6PJ82SL9b3WkGjFavNiA9gm5z6UBxWPiu4CYjptg=" crossorigin="anonymous" defer></script>
<script src="/js/third-party/search/local-search.js" defer></script>

  <script class="next-config" data-name="pdf" type="application/json">{"object_url":{"url":"https://cdn.jsdelivr.net/npm/pdfobject@2.3.1/pdfobject.min.js","integrity":"sha256-jI72I8ZLVflVOisZIOaLvRew3tyvzeu6aZXFm7P7dEo="},"url":"/lib/pdf/web/viewer.html"}</script>
  <script src="/js/third-party/tags/pdf.js" defer></script>



  <script src="/js/third-party/fancybox.js" defer></script>



  
  <script data-pjax async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




  <script src="https://cdn.jsdelivr.net/npm/quicklink@3.0.1/dist/quicklink.umd.js" integrity="sha256-44BednzIpUeQJcY8qtLyarFu0UCCTbgmWOvaoehiFQQ=" crossorigin="anonymous" defer></script>
  <script class="next-config" data-name="quicklink" type="application/json">{"enable":true,"home":true,"archive":true,"delay":true,"timeout":3000,"priority":true,"ignores":null,"url":"https://www.xiaosige.com/post/e3fb4d65.html"}</script>
  <script src="/js/third-party/quicklink.js" defer></script>
<!-- https://www.layuicdn.com/layui/css/layui.css -->
<script src="https://www.layuicdn.com/layui/layui.js"></script>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>


<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.4/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/splitting@1.0.6/dist/splitting.min.js"></script>
<style type="text/css">
    .char{
      font-variation-settings: 'wght' var(--weight, 100);
      color: hsl(var(--hue), calc(var(--saturation) * 1%), 65%);
    }
</style>



<link rel="stylesheet" type="text/css" href="/css/shake.css" />


<link rel="stylesheet" type="text/css" href="/css/hover.css" />


<link rel="stylesheet" type="text/css" href="/zone/css/i_hover.css" />
<link rel="stylesheet" type="text/css" href="/css/injector/main.css" /><link rel="preload" as="style" href="/css/injector/light.css" /><link rel="preload" as="style" href="/css/injector/dark.css" />
  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>

<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="小四儿" type="application/atom+xml">
<link rel="alternate" href="/rss2.xml" title="小四儿" type="application/rss+xml"><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">小四儿</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">心之所愿，无所不至！</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">61</span></a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">25</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">149</span></a></li><li class="menu-item menu-item-welfare"><a href="/welfare" rel="section"><i class="fa fa-star fa-fw"></i>收藏</a></li><li class="menu-item menu-item-music"><a href="/music" rel="section"><i class="fa fa-music fa-fw"></i>音乐</a></li><li class="menu-item menu-item-photos"><a href="/photos" rel="section"><i class="fa fa-camera-retro fa-fw"></i>相册</a></li><li class="menu-item menu-item-links"><a href="/links" rel="section"><i class="fa fa-link fa-fw"></i>友链</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
      <div class="search-header">
        <span class="search-icon">
          <i class="fa fa-search"></i>
        </span>
        <div class="search-input-container">
          <input autocomplete="off" autocapitalize="off" maxlength="80"
                placeholder="搜索..." spellcheck="false"
                type="search" class="search-input">
        </div>
        <span class="popup-btn-close" role="button">
          <i class="fa fa-times-circle"></i>
        </span>
      </div>
      <div class="search-result-container">
        <div class="search-result-icon">
          <i class="fa fa-spinner fa-pulse fa-5x"></i>
        </div>
      </div>
    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85harbor%E4%B9%8B%E5%89%8D%E5%85%88%E5%AE%89%E8%A3%85docker"><span class="nav-number">1.</span> <span class="nav-text">安装harbor之前先安装docker</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%87%86%E5%A4%87"><span class="nav-number">1.1.</span> <span class="nav-text">准备</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%A6%81%E7%94%A8iptables%E5%92%8Cfirewalld%E6%9C%8D%E5%8A%A1"><span class="nav-number">1.1.1.</span> <span class="nav-text">禁用iptables和firewalld服务</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%A6%81%E7%94%A8selinux"><span class="nav-number">1.1.2.</span> <span class="nav-text">禁用selinux</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BF%AE%E6%94%B9%E4%B8%BB%E6%9C%BA%E5%90%8D"><span class="nav-number">1.1.3.</span> <span class="nav-text">修改主机名</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AE%89%E8%A3%85%E5%9F%BA%E7%A1%80%E8%BD%AF%E4%BB%B6%E5%8C%85"><span class="nav-number">1.1.4.</span> <span class="nav-text">安装基础软件包</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AE%89%E8%A3%85docker-ce"><span class="nav-number">1.1.5.</span> <span class="nav-text">安装docker-ce</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%85%8D%E7%BD%AEdocker-ce%E5%9B%BD%E5%86%85yum%E6%BA%90%EF%BC%88%E9%98%BF%E9%87%8C%E4%BA%91%EF%BC%89"><span class="nav-number">1.1.6.</span> <span class="nav-text">配置docker-ce国内yum源（阿里云）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AE%89%E8%A3%85docker%E4%BE%9D%E8%B5%96%E5%8C%85"><span class="nav-number">1.1.7.</span> <span class="nav-text">安装docker依赖包</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AE%89%E8%A3%85docker-ce-1"><span class="nav-number">1.1.8.</span> <span class="nav-text">安装docker-ce</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1"><span class="nav-number">1.1.9.</span> <span class="nav-text">启动服务</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8Bdocker%E7%89%88%E6%9C%AC"><span class="nav-number">1.1.10.</span> <span class="nav-text">查看docker版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AE%89%E8%A3%85docker-compose-%E4%B8%BB%E8%A6%81%E7%94%A8%E4%BA%8Eharbor%E5%AE%89%E8%A3%85%E5%92%8C%E7%AE%A1%E7%90%86"><span class="nav-number">1.1.11.</span> <span class="nav-text">安装docker-compose (主要用于harbor安装和管理)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%BC%80%E5%90%AF%E5%8C%85%E8%BD%AC%E5%8F%91%E5%8A%9F%E8%83%BD%E5%92%8C%E4%BF%AE%E6%94%B9%E5%86%85%E6%A0%B8%E5%8F%82%E6%95%B0"><span class="nav-number">1.1.12.</span> <span class="nav-text">开启包转发功能和修改内核参数</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%BAHarbor%E8%87%AA%E7%AD%BE%E5%8F%91%E8%AF%81%E4%B9%A6"><span class="nav-number">2.</span> <span class="nav-text">为Harbor自签发证书</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%B7%AF%E5%BE%84"><span class="nav-number">2.1.</span> <span class="nav-text">路径</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%94%9F%E6%88%90ca%E8%AF%81%E4%B9%A6"><span class="nav-number">2.1.1.</span> <span class="nav-text">生成ca证书</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%94%9F%E6%88%90%E5%9F%9F%E5%90%8D%E7%9A%84%E8%AF%81%E4%B9%A6"><span class="nav-number">2.1.2.</span> <span class="nav-text">生成域名的证书</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%AD%BE%E5%8F%91%E8%AF%81%E4%B9%A6"><span class="nav-number">2.1.3.</span> <span class="nav-text">签发证书</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85Harbor"><span class="nav-number">3.</span> <span class="nav-text">安装Harbor</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%B8%8B%E8%BD%BDharbor"><span class="nav-number">3.0.1.</span> <span class="nav-text">下载harbor</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%A7%A3%E5%8E%8B%E5%8C%85%EF%BC%8C%E5%B9%B6%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-number">3.0.2.</span> <span class="nav-text">解压包，并修改配置文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AE%89%E8%A3%85harbor"><span class="nav-number">3.0.3.</span> <span class="nav-text">安装harbor</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8Bharbor%E6%9C%8D%E5%8A%A1%E7%8A%B6%E6%80%81"><span class="nav-number">3.0.4.</span> <span class="nav-text">查看harbor服务状态</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%81%87%E5%88%B0%E7%9A%84%E9%94%99%E8%AF%AF-Network-harbor-harbor-Error"><span class="nav-number">3.0.5.</span> <span class="nav-text">遇到的错误 Network harbor_harbor Error</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%9C%A8%E8%87%AA%E5%B7%B1%E7%94%B5%E8%84%91%E4%BF%AE%E6%94%B9hosts%E6%96%87%E4%BB%B6"><span class="nav-number">3.0.6.</span> <span class="nav-text">在自己电脑修改hosts文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E5%81%9C%E6%8E%89harbor"><span class="nav-number">3.0.7.</span> <span class="nav-text">如何停掉harbor</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8harbor"><span class="nav-number">3.0.8.</span> <span class="nav-text">如何启动harbor</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Harbor-%E5%9B%BE%E5%83%8F%E5%8C%96%E7%95%8C%E9%9D%A2%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E"><span class="nav-number">3.0.9.</span> <span class="nav-text">Harbor 图像化界面使用说明</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%B5%8B%E8%AF%95%E4%BD%BF%E7%94%A8harbor%E7%A7%81%E6%9C%89%E9%95%9C%E5%83%8F%E4%BB%93%E5%BA%93"><span class="nav-number">4.</span> <span class="nav-text">测试使用harbor私有镜像仓库</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BF%AE%E6%94%B9docker%E9%85%8D%E7%BD%AE%EF%BC%8C%E5%B9%B6%E9%87%8D%E5%90%AFdocker"><span class="nav-number">4.0.1.</span> <span class="nav-text">修改docker配置，并重启docker</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%91%BD%E4%BB%A4%E8%A1%8Cdocker%E7%99%BB%E5%BD%95harbor%EF%BC%88%E5%A6%82%E6%9E%9C%E4%BD%A0%E6%9C%89%E5%85%B6%E4%BB%96docker%E6%9C%BA%E5%99%A8%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%86%85%E7%BD%91%E8%BF%9C%E7%A8%8B%E7%99%BB%E5%BD%95%EF%BC%89"><span class="nav-number">4.0.2.</span> <span class="nav-text">命令行docker登录harbor（如果你有其他docker机器，可以内网远程登录）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-%E6%8B%89%E5%8F%96tomcat%E9%95%9C%E5%83%8F"><span class="nav-number">4.0.3.</span> <span class="nav-text">docker 拉取tomcat镜像</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BB%8Eharbor%E4%BB%93%E5%BA%93%E4%B8%8B%E8%BD%BD%E9%95%9C%E5%83%8F"><span class="nav-number">4.0.4.</span> <span class="nav-text">从harbor仓库下载镜像</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="leeze"
      src="https://static.xiaosige.com/img/avatar/avatar.jpg">
  <p class="site-author-name" itemprop="name">leeze</p>
  <div class="site-description" itemprop="description">因上努力，果上随缘！</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">149</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">61</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/leeze2012" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;leeze2012" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://www.teambition.com/" title="Teambition → https:&#x2F;&#x2F;www.teambition.com" rel="noopener me" target="_blank"><i class="fab fa-mixcloud fa-fw"></i>Teambition</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/leeze" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;leeze" rel="noopener me" target="_blank"><i class="fab fa-gg fa-fw"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://www.jianshu.com/u/e4c5daf92fa6" title="简书 → https:&#x2F;&#x2F;www.jianshu.com&#x2F;u&#x2F;e4c5daf92fa6" rel="noopener me" target="_blank"><i class="fab fa-telegram fa-fw"></i>简书</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://codeup.aliyun.com/" title="Codeup → https:&#x2F;&#x2F;codeup.aliyun.com" rel="noopener me" target="_blank"><i class="fab fa-envira fa-fw"></i>Codeup</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://blog.csdn.net/lileeze" title="CSDN → https:&#x2F;&#x2F;blog.csdn.net&#x2F;lileeze" rel="noopener me" target="_blank"><i class="fa fa-crosshairs fa-fw"></i>CSDN</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://dev.tencent.com/u/leeze" title="腾讯云 → https:&#x2F;&#x2F;dev.tencent.com&#x2F;u&#x2F;leeze" rel="noopener me" target="_blank"><i class="fab fa-jsfiddle fa-fw"></i>腾讯云</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://www.upyun.com/" title="又拍云 → https:&#x2F;&#x2F;www.upyun.com" rel="noopener me" target="_blank"><i class="fab fa-jsfiddle fa-fw"></i>又拍云</a>
      </span>
  </div>

<div class="site-overview-item animated" style="height:140px;">
    <div class="wrap">
        <div class="cup">
            <div class="cup__mouse"></div>
            <div class="cup__eyes"></div>
            <div class="cup__label">多喝水</div>
        </div>
        <div class="cup-shadow"></div>
    </div>
</div>

<style>

.wrap {
  width: 210px;
  height: 90px;
  -webkit-transform: translate(-50%, 50%);
          transform: translate(-50%, 50%);
  position: relative;
  left: 40%;
  /*top: 20%;*/
}

.cup {
  width: 140px;
  height: 100px;
  background: #FFF;
  box-shadow: inset 0px -10px 0 0 #EDDFE6;
  border-radius: 5px 5px 50px 50px;
  -webkit-transform-origin: bottom center;
          transform-origin: bottom center;
  -webkit-animation: .6s linear 0s infinite alternate cup;
          animation: .6s linear 0s infinite alternate cup;
  border: 3px solid #000;
  position: absolute;
  bottom: 0;
  left: 40px;
  z-index: 2;
}
.cup::before {
  content: '';
  width: 140px;
  background: #91ECED;
  height: 40px;
  border-radius: 100%;
  border: 3px solid #000;
  box-shadow: inset 0 20px 0 0 #fff;
  -webkit-animation: .6s linear 0s infinite alternate water;
          animation: .6s linear 0s infinite alternate water;
  position: absolute;
  top: -20px;
  left: -3px;
}
.cup::after {
  content: '';
  width: 22px;
  height: 26px;
  background: transparent;
  border-radius: 30% 100% 100% 30%;
  border: 3px solid #000;
  border-left: none;
  box-shadow: 4px 0 0 9px #fff, 6px 0 0 10px #000;
  position: absolute;
  bottom: 35px;
  right: -20px;
}
.cup__mouse {
  top: 45px;
  left: 45px;
  position: absolute;
  height: 30px;
  width: 50px;
  border: 3px solid #000;
  border-radius: 50%;
  -webkit-clip-path: polygon(50% 10%, 91% 100%, 5% 100%);
          clip-path: polygon(50% 10%, 91% 100%, 5% 100%);
}
.cup__eyes {
  width: 15px;
  height: 15px;
  background: #000;
  border-radius: 50%;
  box-shadow: 58px 0 0 0 #000;
  position: absolute;
  top: 55px;
  left: 35px;
}
.cup__label {
  width: 48px;
  height: 35px;
  box-sizing: content-box;
  /*padding-top: 10px;*/
  background: #ff7600;
  border: 2px solid #000;
  border-bottom: none;
  -webkit-transform-origin: top center;
          transform-origin: top center;
  -webkit-animation: .6s linear 0s infinite alternate label;
          animation: .6s linear 0s infinite alternate label;
  position: absolute;
  top: 40px;
  left: 45px;
  color: #fff
}
.cup__label::before {
  content: '';
  width: 3px;
  height: 15px;
  background: #000;
  -webkit-animation: .6s linear 0s infinite alternate label-line;
          animation: .6s linear 0s infinite alternate label-line;
  position: absolute;
  left: 25px;
  top: -16px;
}
.cup__label::after {
  content: '';
  position: absolute;
  left: -1px;
  bottom: 0;
  width: 0;
  height: 0;
  -webkit-filter: drop-shadow(0 -2px 0 black);
          filter: drop-shadow(0 -2px 0 black);
  border-bottom: 7px solid #fff;
  border-left: 26px solid transparent;
  border-right: 26px solid transparent;
}

.cup-shadow {
  width: 135px;
  height: 90px;
  background: #7CE589;
  border-radius: 40% 40% 100% 100%;
  -webkit-transform-origin: bottom center;
          transform-origin: bottom center;
  -webkit-animation: .6s linear 0s infinite alternate shadow;
          animation: .6s linear 0s infinite alternate shadow;
  position: absolute;
  bottom: -16px;
  left: 55px;
  z-index: 1;
}
.cup-shadow::after {
  content: '';
  width: 20px;
  height: 25px;
  background: transparent;
  border-radius: 30% 100% 100% 30%;
  border-left: none;
  box-shadow: 5px 0 0 5px #7CE589;
  position: absolute;
  bottom: 35px;
  right: -10px;
}

@-webkit-keyframes cup {
  0% {
    -webkit-transform: rotate(10deg);
            transform: rotate(10deg);
    box-shadow: inset -10px -10px 0 0 #EDDFE6;
  }
  100% {
    -webkit-transform: rotate(-10deg);
            transform: rotate(-10deg);
    box-shadow: inset 10px -10px 0 0 #EDDFE6;
  }
}

@keyframes cup {
  0% {
    -webkit-transform: rotate(10deg);
            transform: rotate(10deg);
    box-shadow: inset -10px -10px 0 0 #EDDFE6;
  }
  100% {
    -webkit-transform: rotate(-10deg);
            transform: rotate(-10deg);
    box-shadow: inset 10px -10px 0 0 #EDDFE6;
  }
}
@-webkit-keyframes water {
  0% {
    box-shadow: inset 30px 20px 0 0 #fff;
  }
  100% {
    box-shadow: inset -30px 20px 0 0 #fff;
  }
}
@keyframes water {
  0% {
    box-shadow: inset 30px 20px 0 0 #fff;
  }
  100% {
    box-shadow: inset -30px 20px 0 0 #fff;
  }
}
@-webkit-keyframes label {
  0% {
    -webkit-transform: rotate(40deg);
            transform: rotate(40deg);
  }
  100% {
    -webkit-transform: rotate(-40deg);
            transform: rotate(-40deg);
  }
}
@keyframes label {
  0% {
    -webkit-transform: rotate(40deg);
            transform: rotate(40deg);
  }
  100% {
    -webkit-transform: rotate(-40deg);
            transform: rotate(-40deg);
  }
}
@-webkit-keyframes label-line {
  0% {
    height: 15px;
    top: -16px;
  }
  25% {
    height: 22px;
    top: -22px;
  }
  50% {
    height: 15px;
    top: -16px;
  }
  100% {
    height: 22px;
    top: -22px;
  }
}
@keyframes label-line {
  0% {
    height: 15px;
    top: -16px;
  }
  25% {
    height: 22px;
    top: -22px;
  }
  50% {
    height: 15px;
    top: -16px;
  }
  100% {
    height: 22px;
    top: -22px;
  }
}
@-webkit-keyframes shadow {
  0% {
    -webkit-transform: skewX(-10deg);
            transform: skewX(-10deg);
  }
  100% {
    -webkit-transform: skewX(20deg);
            transform: skewX(20deg);
  }
}
@keyframes shadow {
  0% {
    -webkit-transform: skewX(-10deg);
            transform: skewX(-10deg);
  }
  100% {
    -webkit-transform: skewX(20deg);
            transform: skewX(20deg);
  }
}

.sidebar-panel{
    min-height: calc(var(--sidebar-wrapper-height) * 0.75);
}
.sidebar-toc-active .post-toc-wrap,
.sidebar-overview-active .site-overview-wrap {
  display: block;
}
</style>




<script src="/zone/js/canvasTime.js" async></script>
<div style="display:none;">
  <canvas id="canvas" style="width:60%;">当前浏览器不支持canvas，请更换浏览器后再试</canvas>
</div>
<style>
// 粒子时钟样式
.site-overview {
  text-align: center;
}

canvas#canvas {
  margin-top: 70px;
}
</style>


<div class="site-overview-item animated">
    <div style="">
        <iframe id="sjFrame" loading="lazy" src="/zone/tool/sj/index.html" border="0" width="100%" height="100" frameborder="no"> </iframe>
    </div>
</div>

        </div>
      </div>
    </div>

    
        <div class="pjax">
        </div>
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://www.xiaosige.com/post/e3fb4d65.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://static.xiaosige.com/img/avatar/avatar.jpg">
      <meta itemprop="name" content="leeze">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="小四儿">
      <meta itemprop="description" content="因上努力，果上随缘！">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="【Docker】之Harbor私有镜像仓库 | 小四儿">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          【Docker】之Harbor私有镜像仓库
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>
      

      <time title="创建时间：2023-11-24 08:35:50 / 修改时间：15:12:16" itemprop="dateCreated datePublished" datetime="2023-11-24T08:35:50+08:00">2023-11-24</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Docker/" itemprop="url" rel="index"><span itemprop="name">Docker</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
<span class="post-meta-item">
    
    
        <span class="post-meta-item-text hvr-bubble-float-left" style="margin: 0 0.5em;box-shadow: 0 15px 18px -6px #00d27a;">
                <a class="article-topping zhuanzai" target="_blank" href="https://www.zhihu.com/question/605667299"><i class="fa fa-link fa-fw zhuanzai_i"></i>转载</a>
        </span>
</span>



    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>10k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>9 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h2 id="安装harbor之前先安装docker"><a href="#安装harbor之前先安装docker" class="headerlink" title="安装harbor之前先安装docker"></a>安装harbor之前先安装docker</h2><h3 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h3><h4 id="禁用iptables和firewalld服务"><a href="#禁用iptables和firewalld服务" class="headerlink" title="禁用iptables和firewalld服务"></a>禁用iptables和firewalld服务</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># systemctl stop firewalld</span>
<span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># systemctl disable firewalld</span>
<span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># systemctl stop iptables</span>
<span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># systemctl disable iptables</span>
<span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment">#  iptables -F  #清空防火墙规则</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<span id="more"></span>

<h4 id="禁用selinux"><a href="#禁用selinux" class="headerlink" title="禁用selinux"></a>禁用selinux</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># setenforce 0 #临时</span>
<span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config *#永久关闭</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h4 id="修改主机名"><a href="#修改主机名" class="headerlink" title="修改主机名"></a>修改主机名</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@master ~<span class="token punctuation">]</span><span class="token comment"># hostnamectl set-hostname harbor </span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># hostname</span>
harbor <span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
<h4 id="安装基础软件包"><a href="#安装基础软件包" class="headerlink" title="安装基础软件包"></a>安装基础软件包</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># yum install -y  wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel  python-devel epel-release openssh-server socat  ipvsadm conntrack</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="安装docker-ce"><a href="#安装docker-ce" class="headerlink" title="安装docker-ce"></a>安装docker-ce</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="配置docker-ce国内yum源（阿里云）"><a href="#配置docker-ce国内yum源（阿里云）" class="headerlink" title="配置docker-ce国内yum源（阿里云）"></a>配置docker-ce国内yum源（阿里云）</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo </span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="安装docker依赖包"><a href="#安装docker依赖包" class="headerlink" title="安装docker依赖包"></a>安装docker依赖包</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># yum install -y yum-utils device-mapper-persistent-data lvm2</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="安装docker-ce-1"><a href="#安装docker-ce-1" class="headerlink" title="安装docker-ce"></a>安装docker-ce</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># yum install docker-ce -y</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="启动服务"><a href="#启动服务" class="headerlink" title="启动服务"></a>启动服务</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment">#  systemctl start docker &amp;&amp; systemctl enable docker</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment">#  systemctl status docker </span>
● docker.service - Docker Application Container Engine
   Loaded: loaded <span class="token punctuation">(</span>/usr/lib/systemd/system/docker.service<span class="token punctuation">;</span> enabled<span class="token punctuation">;</span> vendor preset: disabled<span class="token punctuation">)</span>
   Active: active <span class="token punctuation">(</span>running<span class="token punctuation">)</span> since 二 <span class="token number">2023</span>-06-20 00:07:12 CST<span class="token punctuation">;</span> 11h ago
     Docs: https://docs.docker.com
 Main PID: <span class="token number">46686</span> <span class="token punctuation">(</span>dockerd<span class="token punctuation">)</span>
    Tasks: <span class="token number">50</span>
   Memory: <span class="token number">63</span>.8M
   CGroup: /system.slice/docker.service<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>&nbsp;&nbsp;看到<code>running</code>，表示docker正常运行</p>
<h4 id="查看docker版本"><a href="#查看docker版本" class="headerlink" title="查看docker版本"></a>查看docker版本</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker version</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="安装docker-compose-主要用于harbor安装和管理"><a href="#安装docker-compose-主要用于harbor安装和管理" class="headerlink" title="安装docker-compose (主要用于harbor安装和管理)"></a>安装docker-compose (主要用于harbor安装和管理)</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.21.1/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># chmod +x /usr/bin/docker-compose</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker-compose version</span>

注： 
docker-compose项目是Docker官方的开源项目，负责实现对Docker容器集群的快速编排。
docker-compose的工程配置文件默认为docker-compose.yml，
docker-compose运行目录下的必要有一个docker-compose.yml。
docker-compose可以管理多个docker实例
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h4 id="开启包转发功能和修改内核参数"><a href="#开启包转发功能和修改内核参数" class="headerlink" title="开启包转发功能和修改内核参数"></a>开启包转发功能和修改内核参数</h4><p>&nbsp;&nbsp;内核参数修改：<code>br_netfilter</code>模块用于将桥接流量转发至<code>iptables</code>链，<code>br_netfilter</code>内核参数需要开启转发。</p>
<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment">#  modprobe br_netfilter</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment">#  cat &gt; /etc/sysctl.d/docker.conf &lt;&lt;EOF</span>
net.bridge.bridge-nf-call-ip6tables <span class="token operator">=</span> <span class="token number">1</span>
net.bridge.bridge-nf-call-iptables <span class="token operator">=</span> <span class="token number">1</span>
net.ipv4.ip_forward <span class="token operator">=</span> <span class="token number">1</span>
EOF
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># sysctl -p /etc/sysctl.d/docker.conf</span>

注：
Docker 安装后出现：WARNING: bridge-nf-call-iptables is disabled 的解决办法：
net.bridge.bridge-nf-call-ip6tables <span class="token operator">=</span> <span class="token number">1</span>
net.bridge.bridge-nf-call-iptables <span class="token operator">=</span> <span class="token number">1</span>

net.ipv4.ip_forward <span class="token operator">=</span> <span class="token number">1</span>：
将Linux系统作为路由或者VPN服务就必须要开启IP转发功能。当linux主机有多个网卡时一个网卡收到的信息是否能够传递给其他的网卡 如果设置成1的话 可以进行数据包转发，可以实现VxLAN 等功能。不开启会导致docker部署应用无法访问。

<span class="token comment">#重启docker</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment">#  systemctl restart docker</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="为Harbor自签发证书"><a href="#为Harbor自签发证书" class="headerlink" title="为Harbor自签发证书"></a>为Harbor自签发证书</h2><h3 id="路径"><a href="#路径" class="headerlink" title="路径"></a>路径</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># mkdir /data/ssl -p</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># cd /data/ssl/</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h4 id="生成ca证书"><a href="#生成ca证书" class="headerlink" title="生成ca证书"></a>生成ca证书</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ssl<span class="token punctuation">]</span><span class="token comment">#  openssl genrsa -out ca.key 3072</span>
<span class="token comment">#生成一个3072位的key，也就是私钥</span>
<span class="token punctuation">[</span>root@harbor ssl<span class="token punctuation">]</span><span class="token comment">#  openssl req -new -x509 -days 3650 -key ca.key -out ca.pem</span>
<span class="token comment">#生成一个数字证书ca.pem，3650表示证书的有效时间是3年，按箭头提示填写即可，没有箭头标注的为空：</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>
<img data-src="/post/e3fb4d65/ca.webp" class="" title="生成ca证书">
<h4 id="生成域名的证书"><a href="#生成域名的证书" class="headerlink" title="生成域名的证书"></a>生成域名的证书</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ssl<span class="token punctuation">]</span><span class="token comment"># openssl genrsa -out harbor.key  3072</span>
<span class="token comment">#生成一个3072位的key，也就是私钥</span>
<span class="token punctuation">[</span>root@harbor ssl<span class="token punctuation">]</span><span class="token comment"># openssl req -new -key harbor.key -out harbor.csr</span>
<span class="token comment">#生成一个证书请求，一会签发证书时需要的，标箭头的按提示填写，没有箭头标注的为空：</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>
<img data-src="/post/e3fb4d65/ym.webp" class="" title="生成域名证书">
<h4 id="签发证书"><a href="#签发证书" class="headerlink" title="签发证书"></a>签发证书</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ssl<span class="token punctuation">]</span><span class="token comment"># openssl x509 -req -in harbor.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out harbor.pem -days 3650</span>
<span class="token comment">#显示如下，说明证书签发好了：</span>
Signature ok
<span class="token assign-left variable">subject</span><span class="token operator">=</span>/C<span class="token operator">=</span>CH/ST<span class="token operator">=</span>BJ/L<span class="token operator">=</span>BJ/O<span class="token operator">=</span>Default Company Ltd/CN<span class="token operator">=</span>harbor
Getting CA Private Key<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="安装Harbor"><a href="#安装Harbor" class="headerlink" title="安装Harbor"></a>安装Harbor</h2><h4 id="下载harbor"><a href="#下载harbor" class="headerlink" title="下载harbor"></a>下载harbor</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># cd /opt</span>
<span class="token punctuation">[</span>root@harbor opt<span class="token punctuation">]</span><span class="token comment"># wget https://github.com/goharbor/harbor/releases/download/v2.8.2/harbor-offline-installer-v2.8.2.tgz</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h4 id="解压包，并修改配置文件"><a href="#解压包，并修改配置文件" class="headerlink" title="解压包，并修改配置文件"></a>解压包，并修改配置文件</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor opt<span class="token punctuation">]</span><span class="token comment"># tar xvf harbor-offline-installer-v2.8.2.tgz</span>
<span class="token punctuation">[</span>root@harbor opt<span class="token punctuation">]</span><span class="token comment"># cd harbor &amp;&amp; cp harbor.yml.tmpl harbor.yml</span>
<span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># vim harbor.yml</span>
hostname: reg.mydomain.com 修改为hostname: harbor
  certificate: /your/certificate/path 修改为  certificate: /data/ssl/harbor.pem
  private_key: /your/private/key/path 修改为  private_key: /data/ssl/harbor.key
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h4 id="安装harbor"><a href="#安装harbor" class="headerlink" title="安装harbor"></a>安装harbor</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># ./install.sh </span>

Note: <span class="token function">docker</span> version: <span class="token number">24.0</span>.2

<span class="token punctuation">[</span>Step <span class="token number">1</span><span class="token punctuation">]</span>: checking <span class="token function">docker-compose</span> is installed <span class="token punctuation">..</span>.

Note: Docker Compose version v2.18.1

<span class="token punctuation">[</span>Step <span class="token number">2</span><span class="token punctuation">]</span>: loading Harbor images <span class="token punctuation">..</span>.
Loaded image: goharbor/harbor-log:v2.8.2
Loaded image: goharbor/harbor-db:v2.8.2
Loaded image: goharbor/registry-photon:v2.8.2
Loaded image: goharbor/harbor-core:v2.8.2
Loaded image: goharbor/harbor-jobservice:v2.8.2
Loaded image: goharbor/harbor-registryctl:v2.8.2
Loaded image: goharbor/notary-signer-photon:v2.8.2
Loaded image: goharbor/trivy-adapter-photon:v2.8.2
Loaded image: goharbor/prepare:v2.8.2
Loaded image: goharbor/harbor-portal:v2.8.2
Loaded image: goharbor/redis-photon:v2.8.2
Loaded image: goharbor/harbor-exporter:v2.8.2
Loaded image: goharbor/nginx-photon:v2.8.2
Loaded image: goharbor/notary-server-photon:v2.8.2

作者：洛溪
链接：https://www.zhihu.com/question/605667299/answer/3116890567
来源：知乎
著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。

<span class="token punctuation">[</span>Step <span class="token number">3</span><span class="token punctuation">]</span>: preparing environment <span class="token punctuation">..</span>.

<span class="token punctuation">[</span>Step <span class="token number">4</span><span class="token punctuation">]</span>: preparing harbor configs <span class="token punctuation">..</span>.
prepare base <span class="token function">dir</span> is <span class="token builtin class-name">set</span> to /root/harbor
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input <span class="token function">dir</span>


Note: stopping existing Harbor instance <span class="token punctuation">..</span>.
<span class="token punctuation">[</span>+<span class="token punctuation">]</span> Running <span class="token number">10</span>/10
 ✔ Container nginx              Removed                                                                          <span class="token number">0</span>.1s 
 ✔ Container harbor-jobservice  Removed                                                                          <span class="token number">0</span>.1s 
 ✔ Container registryctl        Removed                                                                          <span class="token number">0</span>.0s 
 ✔ Container harbor-core        Removed                                                                          <span class="token number">0</span>.0s 
 ✔ Container harbor-portal      Removed                                                                          <span class="token number">0</span>.0s 
 ✔ Container registry           Removed                                                                          <span class="token number">0</span>.0s 
 ✔ Container redis              Removed                                                                          <span class="token number">0</span>.0s 
 ✔ Container harbor-db          Removed                                                                          <span class="token number">0</span>.0s 
 ✔ Container harbor-log         Removed
 ✔ Network harbor_harbor        Removed 


<span class="token punctuation">[</span>Step <span class="token number">5</span><span class="token punctuation">]</span>: starting Harbor <span class="token punctuation">..</span>.
<span class="token punctuation">[</span>+<span class="token punctuation">]</span> Building <span class="token number">0</span>.0s <span class="token punctuation">(</span><span class="token number">0</span>/0<span class="token punctuation">)</span>                                                                                               
<span class="token punctuation">[</span>+<span class="token punctuation">]</span> Running <span class="token number">10</span>/10
 ✔ Network harbor_harbor        Created                                                                          <span class="token number">0</span>.1s 
 ✔ Container harbor-log         Started                                                                          <span class="token number">0</span>.5s 
 ✔ Container registryctl        Started                                                                          <span class="token number">2</span>.0s 
 ✔ Container harbor-portal      Started                                                                          <span class="token number">2</span>.1s 
 ✔ Container redis              Started                                                                          <span class="token number">2</span>.2s 
 ✔ Container harbor-db          Started                                                                          <span class="token number">2</span>.1s 
 ✔ Container registry           Started                                                                          <span class="token number">1</span>.9s 
 ✔ Container harbor-core        Started                                                                          <span class="token number">2</span>.3s 
 ✔ Container harbor-jobservice  Started                                                                          <span class="token number">2</span>.7s 
 ✔ Container nginx              Started                                                                          <span class="token number">2</span>.9s 
✔ ----Harbor has been installed and started successfully.----

<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>&nbsp;&nbsp;至此安装成功.</p>
<h4 id="查看harbor服务状态"><a href="#查看harbor服务状态" class="headerlink" title="查看harbor服务状态"></a>查看harbor服务状态</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># docker-compose ps</span>

Name                     Command                  State                             Ports                       
----------------------------------------------------------------------------------------------------------------------
harbor-core         /harbor/entrypoint.sh            Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>                                                     
harbor-db           /docker-entrypoint.sh  <span class="token number">13</span>        Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>                                                     
harbor-jobservice   /harbor/entrypoint.sh            Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>                                                     
harbor-log          /bin/sh <span class="token parameter variable">-c</span> /usr/local/bin/ <span class="token punctuation">..</span>.   Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>   <span class="token number">127.0</span>.0.1:1514-<span class="token operator">&gt;</span><span class="token number">10514</span>/tcp
harbor-portal       nginx <span class="token parameter variable">-g</span> daemon off<span class="token punctuation">;</span>             Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span> 
nginx               nginx <span class="token parameter variable">-g</span> daemon off<span class="token punctuation">;</span>             Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>   <span class="token number">0.0</span>.0.0:80-<span class="token operator">&gt;</span><span class="token number">8080</span>/tcp,:::80-<span class="token operator">&gt;</span><span class="token number">8080</span>/tcp,             
                                                                    <span class="token number">0.0</span>.0.0:443-<span class="token operator">&gt;</span><span class="token number">8443</span>/tcp,:::443-<span class="token operator">&gt;</span><span class="token number">8443</span>/tcp            
redis               redis-server /etc/redis.conf     Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>                                                     
registry            /home/harbor/entrypoint.sh       Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>                                                     
registryctl         /home/harbor/start.sh            Up <span class="token punctuation">(</span>healthy<span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>&nbsp;&nbsp;服务都是正常的</p>
<h4 id="遇到的错误-Network-harbor-harbor-Error"><a href="#遇到的错误-Network-harbor-harbor-Error" class="headerlink" title="遇到的错误 Network harbor_harbor Error"></a>遇到的错误 <code>Network harbor_harbor Error</code></h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">
<span class="token comment">#按照文档按照不会有这个报错，我是安装好docker之后，再关闭防火墙，遇到了这个报错</span>
 ✘ Network harbor_harbor  Error                                                                                  <span class="token number">0</span>.0s 
failed to create network harbor_harbor: Error response from daemon: Failed to Setup IP tables: Unable to <span class="token builtin class-name">enable</span> SKIP DNAT rule:  <span class="token punctuation">(</span>iptables failed: iptables <span class="token parameter variable">--wait</span> <span class="token parameter variable">-t</span> nat <span class="token parameter variable">-I</span> DOCKER <span class="token parameter variable">-i</span> br-4733c61275a3 <span class="token parameter variable">-j</span> RETURN: iptables: No chain/target/match by that name.


<span class="token comment">#方法</span>
<span class="token comment">#这是因为在启动docker的时候防火墙做了策略，如果容器在运行中，停止防火墙，在操作容器就会报这个错误，我们可以重启docker解决此问题</span>

systemctl restart docker.service
<span class="token comment">#然后</span>
<span class="token function">docker-compose</span> up <span class="token parameter variable">-d</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h4 id="在自己电脑修改hosts文件"><a href="#在自己电脑修改hosts文件" class="headerlink" title="在自己电脑修改hosts文件"></a>在自己电脑修改<code>hosts</code>文件</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">在hosts文件添加如下一行，然后保存即可
<span class="token number">192.168</span>.5.135  harbor<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h4 id="如何停掉harbor"><a href="#如何停掉harbor" class="headerlink" title="如何停掉harbor"></a>如何停掉harbor</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># cd /opt/harbor</span>
<span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># docker-compose stop </span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h4 id="如何启动harbor"><a href="#如何启动harbor" class="headerlink" title="如何启动harbor"></a>如何启动harbor</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># cd /opt/harbor</span>
<span class="token punctuation">[</span>root@harbor harbor<span class="token punctuation">]</span><span class="token comment"># docker-compose up -d #docker start启动，有时候nginx启动失败</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h4 id="Harbor-图像化界面使用说明"><a href="#Harbor-图像化界面使用说明" class="headerlink" title="Harbor 图像化界面使用说明"></a>Harbor 图像化界面使用说明</h4><p>&nbsp;&nbsp;在浏览器输入：<a target="_blank" rel="noopener" href="https://harbor/">https://harbor</a></p>
<img data-src="/post/e3fb4d65/fx.webp" class="" title="接受风险并继续">
<p>&nbsp;&nbsp;接收风险并继续，出现如下界面，说明访问正常</p>
<img data-src="/post/e3fb4d65/index.webp" class="" title="harbor首页">

<p>&nbsp;&nbsp;账号：admin<br>&nbsp;&nbsp;密码：Harbor12345</p>
<p>&nbsp;&nbsp;输入账号密码出现如下</p>
<img data-src="/post/e3fb4d65/login.webp" class="" title="harbor登录后">
<p>&nbsp;&nbsp;所有基础镜像都会放在<code>library</code>里面，这是一个公开的镜像仓库<br>&nbsp;&nbsp;新建项目-&gt;起个项目名字test（把访问级别公开那个选中，让项目才可以被公开使用）</p>
<img data-src="/post/e3fb4d65/pro.webp" class="" title="harbor中新建项目">
<img data-src="/post/e3fb4d65/pro001.webp" class="" title="harbor中新建项目后">

<h2 id="测试使用harbor私有镜像仓库"><a href="#测试使用harbor私有镜像仓库" class="headerlink" title="测试使用harbor私有镜像仓库"></a>测试使用harbor私有镜像仓库</h2><h4 id="修改docker配置，并重启docker"><a href="#修改docker配置，并重启docker" class="headerlink" title="修改docker配置，并重启docker"></a>修改<code>docker</code>配置，并重启docker</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># vim /etc/docker/daemon.json</span>
<span class="token punctuation">{</span>  <span class="token string">"registry-mirrors"</span><span class="token builtin class-name">:</span> <span class="token punctuation">[</span><span class="token string">"https://registry.docker-cn.com"</span>,<span class="token string">"https://docker.mirrors.ustc.edu.cn"</span>,<span class="token string">"http://hub-mirror.c.163.com"</span><span class="token punctuation">]</span>,
<span class="token string">"insecure-registries"</span><span class="token builtin class-name">:</span> <span class="token punctuation">[</span><span class="token string">"192.168.5.135"</span>,<span class="token string">"harbor"</span><span class="token punctuation">]</span> <span class="token comment">#表示我们内网访问harbor的时候走的是http，192.168.5.135是安装harbor机器的ip</span>
<span class="token punctuation">}</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># systemctl daemon-reload &amp;&amp; systemctl restart docker</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># systemctl status docker</span>
<span class="token comment">#显示如下，则说明启动成功了</span>
Active: active <span class="token punctuation">(</span>running<span class="token punctuation">)</span> since 二 <span class="token number">2023</span>-06-20 00:07:12 CST<span class="token punctuation">;</span> 10h ago
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h4 id="命令行docker登录harbor（如果你有其他docker机器，可以内网远程登录）"><a href="#命令行docker登录harbor（如果你有其他docker机器，可以内网远程登录）" class="headerlink" title="命令行docker登录harbor（如果你有其他docker机器，可以内网远程登录）"></a>命令行docker登录harbor（如果你有其他docker机器，可以内网远程登录）</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker login 192.168.5.135</span>
Username: admin
Password: Harbor12345
WARNING<span class="token operator">!</span> Your password will be stored unencrypted <span class="token keyword">in</span> /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/<span class="token comment">#credentials-store</span>

Login Succeeded
<span class="token comment">#登录成功</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h4 id="docker-拉取tomcat镜像"><a href="#docker-拉取tomcat镜像" class="headerlink" title="docker 拉取tomcat镜像"></a>docker 拉取tomcat镜像</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment">#docker pull tomcat</span>
Using default tag: latest
latest: Pulling from library/tomcat
0e29546d541c: Pull complete 
9b829c73b52b: Pull complete 
cb5b7ae36172: Pull complete 
6494e4811622: Pull complete 
668f6fcc5fa5: Pull complete 
dc120c3e0290: Pull complete 
8f7c0eebb7b1: Pull complete 
77b694f83996: Pull complete 
0f611256ec3a: Pull complete 
4f25def12f23: Pull complete 
Digest: sha256:9dee185c3b161cdfede1f5e35e8b56ebc9de88ed3a79526939701f3537a52324
Status: Downloaded newer image <span class="token keyword">for</span> tomcat:latest
docker.io/library/tomcat:latest


<span class="token comment">#把tomcat镜像打标签</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker tag tomcat:latest  192.168.5.135/test/tomcat:v1</span>
<span class="token comment">#执行上面命令就会把192.168.5.135/test/tomcat:v1上传到harbor里的test项目下</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker push 192.168.5.135/test/tomcat:v1</span>
<span class="token comment">#执行上面命令就会把192.168.5.135/test/tomcat:v1上传到harbor里的test项目下</span>
The push refers to repository <span class="token punctuation">[</span><span class="token number">192.168</span>.5.135/test/tomcat<span class="token punctuation">]</span>
3e2ed6847c7a: Pushed 
bd2befca2f7e: Pushed 
59c516e5b6fa: Pushed 
3bb5258f46d2: Pushed 
832e177bb500: Pushed
f9e18e59a565: Pushed 
26a504e63be4: Pushed 
8bf42db0de72: Pushed 
31892cc314cb: Pushed 
11936051f93b: Pushed 
v1: digest: sha256:e6d65986e3b0320bebd85733be1195179dbce481201a6b3c1ed27510cfa18351 size: <span class="token number">2422</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>&nbsp;&nbsp;打开<code>harbor</code>控制台，查看</p>
<img data-src="/post/e3fb4d65/jx.webp" class="" title="harbor上传镜像成功">
<h4 id="从harbor仓库下载镜像"><a href="#从harbor仓库下载镜像" class="headerlink" title="从harbor仓库下载镜像"></a>从harbor仓库下载镜像</h4><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">
<span class="token comment"># 在harbor机器上删除镜像</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker rmi -f 192.168.5.135/test/tomcat:v1</span>
Untagged: <span class="token number">192.168</span>.5.135/test/tomcat:v1
Untagged: <span class="token number">192.168</span>.5.135/test/tomcat@sha256:e6d65986e3b0320bebd85733be1195179dbce481201a6b3c1ed27510cfa18351 
<span class="token comment">#从harbor仓库再次拉取镜像</span>
<span class="token punctuation">[</span>root@harbor ~<span class="token punctuation">]</span><span class="token comment"># docker pull 192.168.5.135/test/tomcat:v1</span>
v1: Pulling from test/tomcat
Digest: sha256:e6d65986e3b0320bebd85733be1195179dbce481201a6b3c1ed27510cfa18351
Status: Downloaded newer image <span class="token keyword">for</span> <span class="token number">192.168</span>.5.135/test/tomcat:v1
<span class="token number">192.168</span>.5.135/test/tomcat:v1 

<span class="token comment">#从自己的harbor拉取镜像,速度是很畅快的</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<link rel="stylesheet" href="/css/spoiler.css" type="text/css"><script src="/js/spoiler.js" type="text/javascript" async></script>
    </div>

    
    
    

    <footer class="post-footer">
<div style="padding-top: 26px;">
    

    <div class="endlan">
        <i></i>
        <p>本文结束--- <img src="https://static.xiaosige.com/img/logo.png" style="display:inline-block;margin-bottom:-7px;height: 25px;"> ---感谢您的阅读</p>
    </div>


    <p id="hitokoto" style="text-align:center;margin-top: 30px;font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, STKaiti, KaiTi, SimKai, DFKai-SB, 'Lato', 'PingFang SC', 'Microsoft YaHei', sans-serif;font-weight: bold;color: #999;">
     正在加载一言...
    </p>
    <div style="margin-top: 30px;">
      <img id="wechat_subscriber_qcode" src="https://static.xiaosige.com/img/reward-container-back.png" alt="leeze wechat" style="max-width: 100%;">
    </div>
    

    
</div>


          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    打赏
  </button>
  <div class="post-reward">
      <div>
        <img src="https://static.xiaosige.com/img/wechatpay.png" alt="leeze 微信支付">
        <span>微信支付</span>
      </div>
      <div>
        <img src="https://static.xiaosige.com/img/alipay.png" alt="leeze 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>原文作者： </strong>leeze
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="https://www.xiaosige.com/post/e3fb4d65.html" title="【Docker】之Harbor私有镜像仓库">https://www.xiaosige.com/post/e3fb4d65.html</a>
  </li>
  <li class="post-copyright-license">
      <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/zh-CN" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>

          <div class="post-tags">
              <a href="/tags/Harbor/" rel="tag"><i class="fa fa-tag"></i> Harbor</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/8eeb1ff4.html" rel="prev" title="Linux brctl 安装">
                  <i class="fa fa-angle-left"></i> Linux brctl 安装
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/2cab5b52.html" rel="next" title="Mac&#x2F;Linux之使用Jenv切换java版本">
                  Mac/Linux之使用Jenv切换java版本 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments" id="SOHUCS" sid="ab541cfbbb5049c4bf4862ad6dfc08a9"></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Xiaosige.com 版权所有</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
    <span title="站点总字数">435k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">6:35</span>
  </span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>



<div calss="ypy" style="text-align:center;display:none;">
    本网站由
    <a target="_blank" rel="nofollow noopener" href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" style="border-bottom:none;">
        <img src="https://static.xiaosige.com/img/ypy_logo.png" style="display:inline-block;margin-bottom:-7px;height: 25px;-webkit-filter: brightness(.8);filter: brightness(.8);">
    </a>
    提供CDN加速/云存储服务
</div>


  <div class="beian">
          <img src="https://static.xiaosige.com/img/gongan.png" style="display: inline-block;vertical-align: text-bottom;padding-right: 6px;"><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11011502004362" rel="noopener" target="_blank">京公网安备 11011502004362 </a>
    <span></span><a href="http://beian.miit.gov.cn/" rel="noopener" target="_blank">京ICP备2020038036号-1 </a>
    <span></span>
    本网站由
    <a target="_blank" rel="nofollow noopener" href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" style="border-bottom:none;">
        <img src="https://static.xiaosige.com/img/ypy_logo.png" style="display:inline-block;margin-bottom:-7px;height: 25px;-webkit-filter: brightness(.8);filter: brightness(.8);">
    </a>
    提供CDN加速/云存储服务
  </div>


<link href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js"></script>
<meting-js server="netease" type="playlist" id="2228518256" fixed="true" autoplay="false" order="random" lrc-type=1  theme="#eb7aab"></meting-js>


<div class="bg-box" id="bg-box1"></div>
<div class="bg-box" id="bg-box2"></div>
<style>
.bg-box {
 background-repeat:no-repeat;
 background-attachment:fixed;
 background-position:50% 50%;
 background-size:cover;
 position:fixed;
 left:0;
 right:0;
 top:0;
 bottom:0
}
#bg-box1 {
 z-index:-998
}
#bg-box2 {
 z-index:-999
}
</style>




    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<script class="next-config" data-name="changyan" type="application/json">{"enable":true,"appid":"cyvSPOTJq","appkey":"4436699688bbb9caa6e8826551a7c0f7"}</script>
<script src="/js/third-party/comments/changyan.js" defer></script>
<!-- 提示信息 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-toast-plugin@1.3.2/dist/jquery.toast.min.css"/>
<script src="https://cdn.jsdelivr.net/npm/jquery-toast-plugin@1.3.2/dist/jquery.toast.min.js"></script>
<!-- 樱花特效(https://cdn.jsdelivr.net/gh/yremp/yremp-js@1.5/sakura.js) -->
<!-- 下雪(圣诞) -->

<!-- 天气 -->

<!-- 文字闪烁（变色） -->
<script>
function magicColor(mode,t){
  t=t||10;
  let elem=document.getElementsByClassName("magic-color");
  if(!elem){
      setTimeout(function(){
          magicColor(mode,t-1);
      },400);
      return;
  }
  if(window.mcHandler==undefined){
      window.mcHandler={elements:[]};
      window.mcHandler.colorIndex=0;
      window.mcHandler.run=function(mode){
          let color=mode=="random"?("rgb("+Math.floor(Math.random()*256)+","+Math.floor(Math.random()*256)+","+Math.floor(Math.random()*256)+",1)"):["#CC0000","#9999CC","#CC3366","#669999","#FFCC00","#00CCCC","#CC00CC"][(window.mcHandler.colorIndex++)%7];
          for(var i=0,L=window.mcHandler.elements.length;i<L;i++)window.mcHandler.elements[i].style.color=color;
      }
  }
  window.mcHandler.elements=elem;
  if(window.mcHandler.timer==undefined){
      window.mcHandler.timer=setInterval(()=>{window.mcHandler.run(mode)},500);
  }
}
magicColor("random");//random为随机颜色，否则为固定颜色随机；上方“闪烁（变色）”字样为固定颜色随机
</script>


<!-- 一言API -->
<!-- 现代写法，推荐 -->
<!-- 兼容低版本浏览器 (包括 IE)，可移除 -->
<script src="https://cdn.jsdelivr.net/npm/bluebird@3.7.2/js/browser/bluebird.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fetch@1.1.0/lib/fetch.min.js"></script>
<!--End-->
<script>
fetch('https://v1.hitokoto.cn')
  .then(function (res){
    return res.json();
  })
  .then(function (data) {
    var hitokoto = document.getElementById('hitokoto');
    if(hitokoto){
      hitokoto.innerHTML = "<i class='fa fa-volume-up magic-color' style='margin-right:6px;'></i>" + data.hitokoto + '——【' + data.from + '】';
    }
  })
  .catch(function (err) {
    console.error(err);
  })
</script>


<!-- 代码块自动隐藏 -->
<script>
$(function(){
    const CODE_MAX_HEIGHT = 200;
    const containers = [];

    // 展开
    $('body').on('click', '.js_unfold_code_btn', function () {
        $(this).closest('.js_highlight_container').addClass('on');
    });
    // 收起
    $('body').on('click', '.js_retract_code_btn', function () {
        const $container = $(this).closest('.js_highlight_container').removeClass('on');
        const winTop = $(window).scrollTop();
        const offsetTop = $container.offset().top;
        $(this).css('top', 0);
        if (winTop > offsetTop) {
            // 设置滚动条位置
            $('body, html').animate({
                scrollTop: $container.offset().top - CODE_MAX_HEIGHT
            }, 600);
        }
    });
    // 滚动事件，触发动画效果
    $(window).on('scroll', function () {
        const scrollTop = $(window).scrollTop();
        const temp = [];
        for (let i = 0; i < containers.length; i++) {
            const item = containers[i];
            const { $container, height, $hide, hasHorizontalScrollbar } = item;
            if ($container.closest('body').length === 0) {
                // 如果 $container 元素已经不在页面上, 则删除该元素
                // 防止pjax页面跳转之后，元素未删除
                continue;
            }
            temp.push(item);
            if (!$container.hasClass('on')) {
                continue;
            }
            const offsetTop = $container.offset().top;
            const hideBtnHeight = $hide.outerHeight();
            // 减去按钮高度，减去底部滚动条高度
            const maxTop = parseInt(height - (hasHorizontalScrollbar ? 17 : 0) - hideBtnHeight);
            let top = parseInt(
                Math.min(
                    Math.max(scrollTop - offsetTop, 0), // 如果小于 0 ，则取 0
                    maxTop,// 如果大于 height ，则取 height
                )
            );
            // 根据 sin 曲线设置"收起阅读"位置
            const halfHeight = parseInt($(window).height() / 2 * Math.sin((top / maxTop) * 90 * (2 * Math.PI/360)));
            $hide.css('top', Math.min(top + halfHeight, maxTop));
        }
        //containers = temp;
    });

    // 添加隐藏容器
    const addCodeWrap = ($node) => {
        const $container = $node.wrap('<div class="js_highlight_container highlight-container"><div class="highlight-wrap"></div></div>').closest('.js_highlight_container');

        // 底部 "阅读更多" 与 侧边栏 "收起阅读"
        const $btn = $(`
        <div class="highlight-footer">
          <a class="js_unfold_code_btn show-btn" href="javascript:;">
              <span class="btn-inner">
                阅读更多<i class="fa fa-angle-right fa-lg" aria-hidden="true"></i>
              </span>
              <div class="btnbg-x"></div>
          </a>
        </div>
        <a class="js_retract_code_btn hide-btn" href="javascript:;"><i class="fa fa-angle-up fa-lg" aria-hidden="true"></i>收起阅读</a>
      `);

        $container.append($btn);
        return $container;
    };

    $('.highlight').each(function () {
        // 防止重复渲染
        if (this.__render__ === true) {
            return true;
        }
        this.__render__ = true;
        const $this = $(this);
        const height = $(this).outerHeight();
        if (height > CODE_MAX_HEIGHT) {
            // 添加展开&收起容器
            const $container = addCodeWrap($this, height);
            containers.push({
                $container,
                height,
                $hide: $container.find('.js_retract_code_btn'),
                hasHorizontalScrollbar: this.scrollWidth > this.offsetWidth,
            });
        }
    });

    $('.line-numbers').each(function () {
        // 防止重复渲染
        if (this.__render__ === true) {
            return true;
        }
        this.__render__ = true;
        const $this = $(this);
        const height = $(this).outerHeight();
        if (height > CODE_MAX_HEIGHT) {
            // 添加展开&收起容器
            const $container = addCodeWrap($this, height);
            containers.push({
                $container,
                height,
                $hide: $container.find('.js_retract_code_btn'),
                hasHorizontalScrollbar: this.scrollWidth > this.offsetWidth,
            });
        }
    });

    $('.table-container').each(function () {
        // 防止重复渲染
        if (this.__render__ === true) {
            return true;
        }
        this.__render__ = true;
        const $this = $(this);
        const height = $(this).outerHeight();
        if (height > CODE_MAX_HEIGHT) {
            // 添加展开&收起容器
            const $container = addCodeWrap($this, height);
            containers.push({
                $container,
                height,
                $hide: $container.find('.js_retract_code_btn'),
                hasHorizontalScrollbar: this.scrollWidth > this.offsetWidth,
            });
        }
    });

});
</script>


<script  type="text/javascript">

layui.use(['jquery', 'layer'], function(){

  var $ = layui.$,layer = layui.layer;

  <!-- wobble窗口摆动特效 -->
  


     var wobbleWindow = function(object, params) {
          var canvas,
              ctx;
          var mousePos = {
              x: 0,
              y: 0
          };
          var isResizing = false;
          var delayId = 0;
          var canvasContent = {};
          var points = {};

          var settings = {};
          settings.name = 'wobblew'; //name
          settings.position = 'relative'; //relative or absolute
          settings.depth = -1; //depth for zIndex
          settings.overflowX = 'visible';
          settings.overflowY = 'visible';
          settings.offsetX = 0; //+ or - value the size of the div
          settings.offsetY = 0; //+ or - value the size of the div
          settings.moveTypeIn = 'move'; //method points follow the mouse
          settings.moveTypeOut = 'wobble'; //method points go back to init position
          settings.wobbleFactor = 0.95; //control the wobble effect
          settings.wobbleSpeed = 0.1; //control the wobble effect
          settings.moveSpeed = 6; //control the move speed
          settings.lineWidth = 1; //lineWidth

          settings.transplantLineColor = false; //true Use Object border-color
          settings.lineColor = ''; //no value = no line. Use hex/rgba values
          settings.transplantBodyColor = true; //true Use Object background Color
          settings.bodyColor = ''; //no value = no body color. Use hex/rgba values
          settings.radius = 50; //
          settings.pointCountX = 7; //quantity of points horizontal. must be an odd int
          settings.pointCountY = 5; //quantity of points vertical. must be an odd int
          settings.movementLeft = true; //enable/disable movement directions
          settings.movementRight = true; //enable/disable movement directions
          settings.movementTop = true; //enable/disable movement directions
          settings.movementBottom = true; //enable/disable movement directions
          settings.autoResize = true; //if true size will be automatically adjusted
          settings.debug = false; //enable/disable debug mode

          // ---
          if (params !== undefined) {
              for (var prop in params) {
                  if (params.hasOwnProperty(prop) && settings.hasOwnProperty(prop)) {
                      settings[prop] = params[prop];
                  }
              }
          }

          // ---
          if (!object) {
              throw Error('\n' + 'No div element found');
          }
          if ((settings.pointCountX % 2) === 0) {
              throw Error('\n' + 'Param pointCountX must be an odd integer');
          }
          if ((settings.pointCountY % 2) === 0) {
              throw Error('\n' + 'Param pointCountY must be an odd integer');
          }

          // ---
          HTMLElement.prototype.__defineGetter__("currentStyle", function() {
              return this.ownerDocument.defaultView.getComputedStyle(this, null);
          });
          // ---
          function init() {
              canvas = document.createElement('canvas');
              canvas.id = settings.name;
              canvas.style.position = 'absolute';
              canvas.style.zIndex = settings.depth.toString();
              canvas.addEventListener('mousemove', mouseMoveHandler);
              canvas.addEventListener('mouseleave', mouseLeaveHandler);
              ctx = canvas.getContext('2d');

              // element.insertBefore(canvas, element.firstChild);
              object.appendChild(canvas);
              object.style.position = settings.position;
              object.style.zIndex = (settings.depth + 1).toString();
              if (settings.overflowX.length > 0) {
                  object.parentElement.style.overflowX = settings.overflowX;
              };
              if (settings.overflowY.length > 0) {
                  object.parentElement.style.overflowY = settings.overflowY;
              };
              if (settings.transplantBodyColor) {
                  if (object.currentStyle.backgroundColor.length > 0) {
                      settings.bodyColor = object.currentStyle.backgroundColor;
                  }
              };
              if (settings.transplantLineColor) {
                  if (object.currentStyle.borderColor.length > 0) {
                      settings.lineColor = object.currentStyle.borderColor;
                  }
              };
              canvasContent.elementWidth = object.offsetWidth;
              canvasContent.elementHeight = object.offsetHeight;
              // ---
              resizeCanvas();
              addWindow();
              animloop();
              // -----------
              if (settings.transplantBodyColor) {
                  if (object.currentStyle.backgroundColor.length > 0) {
                      if (object.className.length > 0) {
                          object.className += ' wobbleTransparentBK';
                      } else {
                          object.className = ' wobbleTransparentBK';
                      };
                  }
              };
              if (settings.transplantLineColor) {
                  if (object.currentStyle.borderColor.length > 0) {
                      if (object.className.length > 0) {
                          object.className += ' wobbleTransparentLine';
                      } else {
                          object.className = ' wobbleTransparentLine';
                      };
                  }
              };
          };

          // ---
          function resizeCanvas() {
              canvasContent.width = canvasContent.elementWidth + settings.offsetX * 2;
              canvasContent.height = canvasContent.elementHeight + settings.offsetY * 2;

              if (settings.radius > 0) { //round,  ceil
                  settings.pointCountX = Math.round(canvasContent.width / settings.radius);
                  settings.pointCountY = Math.round(canvasContent.height / settings.radius);
              };
              if (settings.pointCountX % 2 == 0) {
                  settings.pointCountX = settings.pointCountX + 1;
              };
              if (settings.pointCountY % 2 == 0) {
                  settings.pointCountY = settings.pointCountY + 1;
              };

              points.spaceX = Math.min(canvasContent.elementWidth, canvasContent.width / (settings.pointCountX - 1));
              points.spaceY = Math.min(canvasContent.elementHeight, canvasContent.height / (settings.pointCountY + 1));
              points.radius = Math.ceil(Math.max(points.spaceX, points.spaceY));

              ///--------------new1------------------
              canvasContent.left = 0;
              canvasContent.top = 0;
              settings.canvasWidth = canvasContent.elementWidth;
              if (settings.movementLeft) {
                  canvas.style.left = -points.radius + 'px';
                  settings.canvasWidth += points.radius;
                  canvasContent.left = points.radius - settings.offsetX;
              } else {
                  canvas.style.left = -settings.offsetX + 'px';
              };
              if (settings.movementRight)
                  settings.canvasWidth += points.radius;

              settings.canvasHeight = canvasContent.elementHeight;
              if (settings.movementTop) {
                  canvas.style.top = -points.radius + 'px';
                  settings.canvasHeight += points.radius;
                  canvasContent.top = points.radius - settings.offsetY;
              } else {
                  canvas.style.top = -settings.offsetY + 'px';
              };
              if (settings.movementBottom)
                  settings.canvasHeight += points.radius;

              canvas.width = settings.canvasWidth;
              canvas.height = settings.canvasHeight;
          };

          // ---
          function addWindow() {
              points.pointHolder = [];
              // ---
              var point;
              var flag;
              var i,
                  l;
              // ---
              //top
              flag = true;
              for (i = 0, l = settings.pointCountX; i < l; i++) {
                  if (settings.movementTop) {
                      if (flag) {
                          point = addPoint(canvasContent.left + i * points.spaceX, canvasContent.top, 0, 0, 0, true, points.spaceX, 'P', settings.debug);
                          flag = false;
                      } else {
                          point = addPoint(canvasContent.left + i * points.spaceX, canvasContent.top, 0, 0, 0, true, points.spaceX, 'C', settings.debug);
                          flag = true;
                      }
                      if (i === 0 || i === l - 1) {
                          point.color = '#00FF00';
                          point.movement = false;
                      }
                      points.pointHolder.push(point);
                  } else {
                      if (i === 0 || i === l - 1) {
                          point = addPoint(canvasContent.left + i * points.spaceX, canvasContent.top, 0, 0, 0, false, 0, 'P', settings.debug);
                      }
                      points.pointHolder.push(point);
                  }
              }

              // ---
              //right
              flag = false;
              for (i = 1, l = settings.pointCountY + 1; i < l; i++) {
                  if (settings.movementRight) {
                      if (flag) {
                          point = addPoint(canvasContent.left + canvasContent.width, canvasContent.top + i * points.spaceY, 0, 0, 0, true, points.spaceY, 'P', settings.debug);
                          flag = false;
                      } else {
                          point = addPoint(canvasContent.left + canvasContent.width, canvasContent.top + i * points.spaceY, 0, 0, 0, true, points.spaceY, 'C', settings.debug);
                          flag = true;
                      }
                      points.pointHolder.push(point);
                  } else {
                      if (i === 1) {
                          point = addPoint(canvasContent.left + canvasContent.width, canvasContent.top + (i - 1) * points.spaceY, 0, 0, 0, false, 0, 'P', settings.debug);
                      } else if (i === settings.pointCountY) {
                          point = addPoint(canvasContent.left + canvasContent.width, canvasContent.top + (i + 1) * points.spaceY, 0, 0, 0, false, 0, 'P', settings.debug);
                      }
                      points.pointHolder.push(point);
                  }
              }

              // ---
              //bottom
              flag = true;
              for (i = settings.pointCountX - 1, l = -1; i > l; i--) {
                  if (settings.movementBottom) {
                      if (flag) {
                          point = addPoint(canvasContent.left + i * points.spaceX, canvasContent.top + canvasContent.height, 0, 0, 0, true, points.spaceX, 'P', settings.debug);
                          flag = false;
                      } else {
                          point = addPoint(canvasContent.left + i * points.spaceX, canvasContent.top + canvasContent.height, 0, 0, 0, true, points.spaceX, 'C', settings.debug);
                          flag = true;
                      }
                      if (i === 0 || i === settings.pointCountX - 1) {
                          point.color = '#00FF00';
                          point.movement = false;
                      }
                      points.pointHolder.push(point);
                  } else {
                      if (i === 0 || i === settings.pointCountX - 1) {
                          point = addPoint(canvasContent.left + i * points.spaceX, canvasContent.top + canvasContent.height, 0, 0, 0, false, 0, 'P', settings.debug);
                      }
                      points.pointHolder.push(point);
                  }
              }

              // ---
              //left
              flag = false;
              for (i = settings.pointCountY, l = -1; i > l; i--) {
                  if (settings.movementLeft) {
                      if (flag) {
                          point = addPoint(canvasContent.left, canvasContent.top + i * points.spaceY, 0, 0, 0, true, points.spaceY, 'P', settings.debug);
                          flag = false;
                      } else {
                          point = addPoint(canvasContent.left, canvasContent.top + i * points.spaceY, 0, 0, 0, true, points.spaceY, 'C', settings.debug);
                          flag = true;
                      }
                      points.pointHolder.push(point);
                  } else {
                      if (i === 0) {
                          point = addPoint(canvasContent.left, canvasContent.top + i * points.spaceY, 0, 0, 0, false, 0, 'P', settings.debug);
                      } else if (i === settings.pointCountY) {
                          point = addPoint(canvasContent.left, canvasContent.top + (i + 1) * points.spaceY, 0, 0, 0, false, 0, 'P', settings.debug);
                      }
                      points.pointHolder.push(point);
                  }
              }
          }

          // ---
          function addPoint(x, y, xp, yp, distance, movement, radius, type, visible) {
              var point = {};
              point.x = x;
              point.y = y;
              point.xp = x;
              point.yp = y;
              point.sx = 0;
              point.sy = 0;
              point.distance = distance;
              point.movement = movement;
              point.radius = radius;
              point.type = type;
              point.visible = visible;
              return point;
          };

          // ---
          window.requestAnimFrame = (function() {
              return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) {
                  window.setTimeout(callback, 1000 / 60);
              };
          })();

          function animloop() {
              requestAnimFrame(animloop);
              render();
              if (settings.autoResize) {
                  resize();
              }
          };

          // ---
          function render() {
              ctx.clearRect(0, 0, settings.canvasWidth, settings.canvasHeight);

              // ---
              var windowPoints = points.pointHolder;
              var i,
                  l;

              // ---
              ctx.beginPath();
              ctx.moveTo(windowPoints[0].x, windowPoints[0].y);
              for (i = 1, l = windowPoints.length; i < l; i += 2) {
                  var point = windowPoints[i];

                  // ---
                  var dx = mousePos.x - point.xp;
                  var dy = mousePos.y - point.yp;
                  point.distance = Math.sqrt(dx * dx + dy * dy);
                  if (point.distance < point.radius) {
                      if (settings.moveTypeIn === 'wobble') {
                          point.sx = point.sx * settings.wobbleFactor + (mousePos.x - point.x) * settings.wobbleSpeed;
                          point.sy = point.sy * settings.wobbleFactor + (mousePos.y - point.y) * settings.wobbleSpeed;
                          point.x = point.x + point.sx;
                          point.y = point.y + point.sy;
                      } else if (settings.moveTypeIn === 'move') {
                          point.x -= (point.x - mousePos.x) / settings.moveSpeed;
                          point.y -= (point.y - mousePos.y) / settings.moveSpeed;
                      }
                  } else {
                      if (settings.moveTypeOut === 'wobble') {
                          point.sx = point.sx * settings.wobbleFactor + (point.xp - point.x) * settings.wobbleSpeed;
                          point.sy = point.sy * settings.wobbleFactor + (point.yp - point.y) * settings.wobbleSpeed;
                          point.x = point.x + point.sx;
                          point.y = point.y + point.sy;
                      } else if (settings.moveTypeOut === 'move') {
                          point.x -= (point.x - point.xp) / settings.moveSpeed;
                          point.y -= (point.y - point.yp) / settings.moveSpeed;
                      }
                  }

                  // ---
                  var pointBefor = windowPoints[i - 1];
                  var pointAfter = windowPoints[i + 1];
                  if (i > 2 && i < windowPoints.length - 2) {
                      if (pointBefor.movement) {
                          pointBefor.x = (windowPoints[i - 2].x + point.x) / 2;
                          pointBefor.y = (windowPoints[i - 2].y + point.y) / 2;
                      }
                      if (pointAfter.movement) {
                          pointAfter.x = (windowPoints[i + 2].x + point.x) / 2;
                          pointAfter.y = (windowPoints[i + 2].y + point.y) / 2;
                      }
                  }
                  ctx.quadraticCurveTo(point.x, point.y, pointAfter.x, pointAfter.y);
              }

              // ---
              if (settings.lineColor.length > 0) {
                  ctx.lineWidth = settings.lineWidth;
                  ctx.strokeStyle = settings.lineColor;
                  ctx.stroke();
              }
              if (settings.bodyColor.length > 0) {
                  ctx.fillStyle = settings.bodyColor;
                  ctx.fill();
              }
              // ctx.globalCompositeOperation = 'source-out';
              // ctx.fillStyle = "rgba(0, 0, 0, 1)";
              // ctx.fill();

              // ---
              if (settings.debug) {
                  for (i = 0, l = windowPoints.length; i < l; i++) {
                      var point = windowPoints[i];
                      if (point.visible) {
                          if (point.type === 'P') {
                              drawCircle(point.x, point.y, 3, '#FF0000');
                          } else {
                              drawCircle(point.x, point.y, 6, '#FF00FF');
                          }
                          if (point.color) {
                              drawCircle(point.x, point.y, 12, point.color);
                          }
                      }
                  }
                  ctx.strokeStyle = '#000000';
                  ctx.strokeRect(0, 0, settings.canvasWidth, settings.canvasHeight);
              }
          };

          // ---
          function delayFlag() {
              resizeCanvas();
              addWindow();
              isResizing = false;
          };

          function resize() {
              if (!isResizing) {
                  if (canvasContent.elementWidth !== object.offsetWidth || canvasContent.elementHeight !== object.offsetHeight) {
                      // -----------
                      isResizing = true;
                      canvasContent.elementWidth = object.offsetWidth;
                      canvasContent.elementHeight = object.offsetHeight;
                      // 防止闪白
                      delayId = window.setTimeout(delayFlag, 10);
                  }
              }
          };

          // ---
          function drawCircle(x, y, radius, color) {
              ctx.beginPath();
              ctx.arc(x, y, radius, 0, 2 * Math.PI);
              ctx.strokeStyle = color;
              ctx.stroke();
          };

          // ---
          function mouseMoveHandler(event) {
              mousePos = getMousePos(canvas, event);
          };

          function mouseLeaveHandler(event) {
              mousePos.x = -10000;
              mousePos.y = -10000;
          };

          // ---
          function getMousePos(canvas, event) {
              var rect = canvas.getBoundingClientRect();
              return {
                  x: event.clientX - rect.left,
                  y: event.clientY - rect.top
              };
          };

          // ---
          init();
      };


  var settings = {
        radius: 20,
        wobbleFactor: 0.98,
        wobbleSpeed: 0.05,
        moveSpeed: 3,
        lineWidth: 3,
        lineColor: '#000',
        bodyColor: '#EEE'

  };
/*
  var footers=document.querySelectorAll(".footer");
  wobbleWindow(footers[footers.length-1],{
                radius: 20,
                depth:-2,
                movementBottom: false,
                movementLeft: false,
                movementRight: false,
                debug: false
  });*/

  var postblocks=document.querySelectorAll(".main-inner .post-block ");
  [].forEach.call(postblocks, function(elm) {
      wobbleWindow(elm,settings);
  });

  

});

</script>


<!-- 页面背景图片动态加载 -->
<script>

     //获取指定长度的uuid
     function uuid(len, radix) {
        var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
        var uuid = [], i;
        radix = radix || chars.length;

        if (len) {
          // Compact form
          for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
        } else {
          // rfc4122, version 4 form
          var r;

          // rfc4122 requires these characters
          uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
          uuid[14] = '4';

          // Fill in random data.  At i==19 set the high bits of clock sequence as
          // per rfc4122, sec. 4.1.5
          for (i = 0; i < 36; i++) {
            if (!uuid[i]) {
              r = 0 | Math.random()*16;
              uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
            }
          }
        }

        return uuid.join('');
    }

    function animatechangbgimg(elm,opacityvalue,bgimgurl){
        $(elm).animate(
        　　{opacity:opacityvalue},
        　　"slow",
        　　null,
        　　function(){
               $(elm).css("background-image","url("+bgimgurl+")");
        　　}
        );
    }

    function checktime(time){
        var oldtime = localStorage.getItem("pjax-imgurl-leeze-lastvisitedtime");
        return Math.floor(((new Date).getTime()-oldtime)/1e3) >= time;
    }

    function changbgimgurl(){

          if(checktime(13)){//每次打开新页面，都会触发一个新的调度器，固加入lastvisitedtime校验，确保循环时间
                //var tc = "https://cdn.jsdelivr.net/gh/maplesugarr/blog-assets/imgs/body-bg/body-bg-" + Math.floor(23 * Math.random()) + ".jpg";
                //var bgimgurl = 'https://source.unsplash.com/collection/30327996/2000x1000';
                //var initbgurl = null,newbgurl = "https://cdn.jsdelivr.net/gh/leeze2012/blog-assets/img/body-bg-" + Math.floor(26 * Math.random()) + ".jpg";
                var initbgurl = null,newbgurl = "https://static.xiaosige.com/img/bg/body-bg-" + Math.floor(26 * Math.random()) + ".jpg";
                if(localStorage.hasOwnProperty('pjax-imgurl-leeze')){
                  initbgurl = localStorage.getItem("pjax-imgurl-leeze");
                }else{
                  initbgurl = newbgurl;
                }

                if($("#bg-box1").css('opacity')==="1"){
                      animatechangbgimg("#bg-box1",0,newbgurl);
                      animatechangbgimg("#bg-box2",1,initbgurl);
                }else{
                      animatechangbgimg("#bg-box1",1,initbgurl);
                      animatechangbgimg("#bg-box2",0,newbgurl);
                }

                localStorage.setItem("pjax-imgurl-leeze", newbgurl);
                localStorage.setItem("pjax-imgurl-leeze-lastvisitedtime",(new Date).getTime());
          }

    };

    setInterval(changbgimgurl,15000);

</script>

<!-- 标题文字闪烁效果 -->
<script>

document.getElementsByClassName('site-title')[0].setAttribute('data-splitting','chars');

Splitting();
gsap.set('.char', {
  '--hue': gsap.utils.distribute({
    base: 0,
    amount: 330,
  })
});
gsap.to('.char', {
  '--weight': 700,
  '--saturation': 80,
  ease: 'sine.inOut',
  duration: 0.5,
  stagger: {
    yoyo: true,
    repeat: -1,
    each: 0.15,
  }
}).time(2);
</script>


<script type="text/javascript">
    $(document).ready(function() {
        <!-- 站点作者头像 -->
        if($('.site-author:first').children().first().prop("tagName").toLowerCase() === "img"){
            <!-- 头像站点作者头像连接到关于我 -->
            $('.site-author-image').prop('outerHTML', "<a href='/about' title='关于我'>"+$('.site-author-image').prop("outerHTML")+"</a>");
            <!-- 站点作者头像动画阴影 -->
            $(".site-author-image").hover(function(){
                $(this).toggleClass('site-author-image-yy');
            },function(){
                $(this).toggleClass('site-author-image-yy');
            });
        }
        <!-- 五星好评 -->
        if($("#wpac-rating").length > 0){
            $("#wpac-rating").before("<div style='color: rgba(0, 0, 0, 0.75); font-size:13px; letter-spacing:3px'>(&gt; 看完记得五星好评哦亲 &lt;)</div>");
            $(".wp_rating").css("height","30px");
        }
        if($(".copyright").length > 0){
            <!-- footer追加邮箱 -->
            if($(".leezeEmail").length === 0){
                $(".copyright").append("<span class='leezeEmail post-meta-item'><i style='margin-right:6px;' class='fa fa-fw fa-envelope with-love'></i><a href='mailto:leeze0216@163.com' title='E-Mail → mailto:leeze0216@163.com' target='_blank'>leeze0216@163.com</a></span>");
            }
            <!-- 版权图标 -->
            $(".copyright span[class='with-love']").css("display","none");
        }
        <!-- footer的阅读次数位置调整 -->
        if($(".busuanzi-count").length > 0){
            $(".wordcount").append($(".busuanzi-count").html());
            $(".busuanzi-count").remove();
        }
        <!-- 标签页追加抖动样式 -->
        if($('.tag-cloud-tags a').length > 0){
            $('.tag-cloud-tags a').each(function(){
              $(this).addClass('shake shake-slow');
            });
        }
        <!-- 社交链接增加hover样式 -->
        if($('.links-of-author-item a').length > 0){
            $('.links-of-author-item a').each(function(index,element){
                if((index+1)%2 === 1){
                    $(this).addClass('hvr-bounce-to-right');
                }else{
                    $(this).addClass('hvr-bounce-to-left');
                }
                if($(this).children('i').length > 0){
                    $(this).children('i').addClass('faa-spin');
                }
            });
        }
        <!-- 主菜单hover样式 -->
        if($('.main-menu .menu-item a').length > 0){
            $('.main-menu .menu-item a').each(function(index,element){
                $(this).addClass('hvr-grow-shadow');
                if($(this).children('i').length > 0){
                    $(this).children('i').addClass('faa-wrench');
                }
            });
        }
        <!-- 移动端 隐藏音乐 -->
        if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
            $('meting-js').css('display','none');
        }

        <!-- 转载 -->
        if($('.zhuanzai').length > 0){
            $('.zhuanzai').each(function(index,element){
                $(this).hover(function(){
                    var tipmsg = this.getAttribute('href');
                    if( tipmsg === 'javascript:;'){
                        tipmsg = "抱歉，忘记转载地址了！";
                    }
                    layer.tips(tipmsg, $(this), {
                      tips: 3
                    });
                },function(){
                    layer.closeAll('tips');
                });
            });
        }

    });
</script>
<!-- 自定义 -->
<script src="/zone/js/leeze.js"></script>
<div class="moon-menu">
  <div class="moon-menu-items">
    
    <div id="moon-menu-item-back2bottom" class="moon-menu-item" onclick="back2bottom()">
      <i class='fa fa-chevron-down'></i>    </div>
    
    <div id="moon-menu-item-back2top" class="moon-menu-item" onclick="back2top()">
      <i class='fa fa-chevron-up'></i>    </div>
    
  </div>
  <div class="moon-menu-button">
    <svg class="moon-menu-bg">
      <circle class="moon-menu-cricle" cx="50%" cy="50%" r="44%"></circle>
      <circle class="moon-menu-border" cx="50%" cy="50%" r="48%"></circle>
    </svg>
    <div class="moon-menu-content">
      <div class="moon-menu-icon"><i class='fas fa-ellipsis-v'></i></div>
      <div class="moon-menu-text"></div>
    </div>
  </div>
</div><script src="/js/injector.js"></script><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</body>
</html>
